﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddCustomer.aspx.cs" Inherits="Manager_User_AddCustomer"
   %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="../../Pub/Css/BodyStyles.css" rel="stylesheet" type="text/css" />
    <link href="../../Pub/Css/AdminStyles.css" rel="stylesheet" type="text/css" />
</head>
<body onload="IsAutoPassWord()" style="overflow: hidden">
    <form id="form1" runat="server">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tbl_News">
            <tr>
                <td class="td_TitileNews_590">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="td_Content_590">
                    <table width="100%" style="padding-left: 20px; padding-right: 25px" cellpadding="0"
                        cellspacing="0">
                        <tr>
                            <td align="center">
                                <table border="0" class="tbl_Register" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td align="right" style="height: 223px" valign="middle">
                                            <table cellpadding="1" cellspacing="0" class="tbl_Info" width="100%">
                                                <tr>
                                                    <td align="left" class="td_SubRegisterTitle" colspan="2" style="font-family: tahoma">
                                                        <asp:Label ID="lblTextTiltle" runat="server" Text="Thông tin khách hàng" Font-Size="14px"
                                                            Font-Bold="True"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 95px">
                                                    </td>
                                                    <td align="left" style="width: 400px">
                                                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="GrRegister"
                                                            CssClass="valid_common" ShowMessageBox="True" ShowSummary="False" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" nowrap style="width: 95px">
                                                        &nbsp;<asp:Label ID="Label4" runat="server" Text="Tên:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left">
                                                        <asp:TextBox ID="txtName" runat="server" ValidationGroup="GrRegister" Width="80%"
                                                            CssClass="txt_Common"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                                                            ErrorMessage="Nhập vào tên khách hàng" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 95px">
                                                        &nbsp; &nbsp;<asp:Label ID="Label8" runat="server" Text="Điện thoại:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left">
                                                        <asp:TextBox ID="txtPhone" runat="server" ValidationGroup="GrRegister" CssClass="txt_Common"
                                                            Width="50%"></asp:TextBox>
                                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtPhone"
                                                            ErrorMessage="Số điện thoại phải là số" ValidationExpression="^\d+$" ValidationGroup="GrRegister"
                                                            CssClass="valid_common">*</asp:RegularExpressionValidator>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 95px">
                                                        &nbsp;<asp:Label ID="Label7" runat="server" Text="Địa chỉ:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left" style="width: 400px; color: #ff6600">
                                                        <span style="font-family: Arial"></span>
                                                        <asp:TextBox ID="txtAddress" runat="server" ValidationGroup="GrRegister" CssClass="txt_Common"
                                                            Width="80%"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtAddress"
                                                            ErrorMessage="Nhập vào địa chỉ" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                                                </tr>
                                                <tr>
                                                    <td align="right" nowrap>
                                                        <asp:Label ID="Label10" runat="server" Text="Tỉnh/Thành phố:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left">
                                                        <asp:DropDownList ID="ddlPlace" runat="server">
                                                        </asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 114px">
                                                        <asp:Label ID="Label14" runat="server" CssClass="lbl_Common" Text="Mã số thuế:"></asp:Label></td>
                                                    <td align="left">
                                                        <asp:TextBox ID="txtTaxNo" runat="server" CssClass="txt_Common" Width="50%"></asp:TextBox>
                                                        <asp:Label ID="Label15" runat="server" CssClass="valid_common" Font-Names="tahoma"
                                                            Font-Size="10pt" ForeColor="Red" Text="(Nếu có)"></asp:Label></td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 114px">
                                                        &nbsp;<asp:Label ID="Label9" runat="server" Text="Email:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left" nowrap>
                                                        <asp:TextBox ID="txtEmail" runat="server" onblur="fnCheckEmail(this.value)" onkeyup="fnHideImgEmail()"
                                                            ValidationGroup="GrRegister" CssClass="txt_Common" Width="80%"></asp:TextBox>&nbsp;
                                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                                                            ErrorMessage="Nhập chính xác địa chỉ Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                            ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RegularExpressionValidator>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator51" runat="server" ControlToValidate="hidEmail"
                                                            ErrorMessage="Email này đã được sử dụng" InitialValue="0" ValidationGroup="GrRegister"
                                                            CssClass="valid_common"> &nbsp;</asp:RequiredFieldValidator>&nbsp;
                                                        <img src="../../Images/Icon/spinner.gif" border="0" id="imgStateEmail" style="visibility: hidden" />
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator52" runat="server" ControlToValidate="hidEmail"
                                                            ErrorMessage="Đang xử lý..." ValidationGroup="GrRegister" CssClass="valid_common">Đang xử lý...</asp:RequiredFieldValidator>
                                                        <asp:TextBox ID="hidEmail" runat="server" CssClass="cssHidden" Text="1" Width="5px"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 114px">
                                                        <asp:Label ID="Label5" runat="server" Text="Ngày sinh:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left">
                                                        <asp:DropDownList ID="drlDay" runat="server" CssClass="ddl_Info">
                                                        </asp:DropDownList>
                                                        <asp:DropDownList ID="drlMonth" runat="server" CssClass="ddl_Info">
                                                        </asp:DropDownList>&nbsp;<asp:DropDownList ID="drlYear" runat="server" CssClass="ddl_Info">
                                                        </asp:DropDownList><span style="font-family: Arial"> </span>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 114px">
                                                        &nbsp;<asp:Label ID="Label6" runat="server" Text="Giới tính:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left" style="width: 400px">
                                                        <asp:DropDownList ID="DrlSex" runat="server" CssClass="ddl_Info">
                                                            <asp:ListItem Selected="True" Value="0">Nam</asp:ListItem>
                                                            <asp:ListItem Value="1">Nữ</asp:ListItem>
                                                        </asp:DropDownList></td>
                                                </tr>
                                                <tr>
                                                    <td align="left" colspan="2">
                                                        <asp:Label ID="Label2" runat="server" Text="Thông tin đăng nhập" Font-Size="14px"
                                                            Font-Bold="True"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="left" colspan="2" nowrap="nowrap">
                                                        <asp:CheckBox ID="chkAutoPass" onclick="IsAutoPassWord()" runat="server" Text="Mật khẩu tự động"
                                                            Checked="True" /></td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 114px">
                                                        <asp:Label ID="Label11" runat="server" Text="Tên truy cập:" CssClass="lbl_Common"></asp:Label></td>
                                                    <td align="left" nowrap>
                                                        <asp:TextBox ID="txtUser" runat="server" onblur="fnCheckUser(this.value)" onkeyup="fnHideImg()"
                                                            ValidationGroup="GrRegister" CssClass="txt_Common" Width="150px"></asp:TextBox><asp:RequiredFieldValidator
                                                                ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtUser" ErrorMessage="Nhập vào tên truy cập"
                                                                ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="hidUser"
                                                            ErrorMessage="Tên truy cập này đã tồn tại" InitialValue="0" ValidationGroup="GrRegister"
                                                            CssClass="valid_common"> &nbsp;</asp:RequiredFieldValidator>&nbsp;
                                                        <img src="../../Images/Icon/spinner.gif" border="0" id="imgState" style="visibility: hidden" />
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="hidUser"
                                                            ErrorMessage="Đang xử lý..." ValidationGroup="GrRegister" CssClass="valid_common">Đang xử lý...</asp:RequiredFieldValidator>
                                                        <asp:TextBox ID="hidUser" runat="server" CssClass="cssHidden" Text="0" Width="5px"></asp:TextBox></td>
                                                </tr>
                                                <tr id="trAut" runat="server" visible="false">
                                                    <td align="right" style="width: 114px">
                                                        <asp:Label ID="Label1" runat="server" CssClass="lbl_Common" Text="Quyền hạn:"></asp:Label></td>
                                                    <td align="left" nowrap="nowrap">
                                                        <asp:DropDownList ID="ddlAut" runat="server" ValidationGroup="GrRegister">
                                                        </asp:DropDownList>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="ddlAut"
                                                            ErrorMessage="Chọn quyền hạn" InitialValue="0" ValidationGroup="GrRegister">*</asp:RequiredFieldValidator></td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <table cellpadding="1" cellspacing="0" width="100%">
                                                            <tr id="trPass1">
                                                                <td align="right" nowrap style="width: 114px">
                                                                    <asp:Label ID="Label12" runat="server" Text="Mật khẩu:" CssClass="lbl_Common"></asp:Label></td>
                                                                <td align="left">
                                                                    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" ValidationGroup="GrRegister"
                                                                        CssClass="txt_Product" Width="150px" CausesValidation="True"></asp:TextBox><asp:RequiredFieldValidator
                                                                            ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtPassword" ErrorMessage="Nhập vào mật khẩu"
                                                                            ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                                                            </tr>
                                                            <tr id="trPass2">
                                                                <td align="right" nowrap style="width: 114px">
                                                                    <asp:Label ID="Label13" runat="server" Text="Gõ lại mật khẩu:" CssClass="lbl_Common"></asp:Label></td>
                                                                <td align="left">
                                                                    <asp:TextBox ID="txtTestPassword" runat="server" TextMode="Password" ValidationGroup="GrRegister"
                                                                        CssClass="txt_Product" Width="150px"></asp:TextBox><asp:CompareValidator ID="CompareValidator1"
                                                                            runat="server" ControlToCompare="txtPassword" ControlToValidate="txtTestPassword"
                                                                            ErrorMessage="Mật khẩu chưa trùng khớp" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:CompareValidator></td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 95px">
                                                    </td>
                                                    <td align="left">
                                                        &nbsp;</td>
                                                </tr>
                                                <tr>
                                                    <td align="right" style="width: 95px">
                                                    </td>
                                                    <td align="left">
                                                        <asp:Button ID="btnSend" runat="server" Text="Bảo lưu" ValidationGroup="GrRegister"
                                                            CssClass="btn_Common" OnClick="btnSend_Click" />
                                                        <asp:Button ID="Button1" runat="server" CssClass="btn_Common" OnClick="Button1_Click"
                                                            Text="Quay lại" /></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>

        <script language="javascript" type="text/javascript">
    // Removes leading whitespaces
     String.prototype.trim = function () {
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}

    /*=================User================*/
    function fnHideImg()
    {
        var imgState=document.getElementById("imgState");
        imgState.style.visibility="hidden"; 
    }
    function fnCheckUser(sValue)
    {     
    
        if(sValue.trim()=="" || sValue.trim().toLowerCase()=="administrator" )
        {   
            var hidUser=document.getElementById("<%= hidUser.ClientID%>");
            hidUser.value="0";
            return;
        }
        var UserID="0";
        if('<%=Request.QueryString["UserID"] %>'!="" && '<%= Request.QueryString["UserID"]%>'!=null)
            UserID='<%=Request.QueryString["UserID"] %>';
    
        Manager_User_AddCustomer.AjaxCheckUser(sValue,UserID,CallBackUser);  
        var imgState=document.getElementById("imgState");
        imgState.style.visibility="visible";
        imgState.src="../../Images/Icon/spinner.gif";     
    }
    function CallBackUser(res)
    {
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgState=document.getElementById("imgState");
			    //var hidUser=document.getElementById("ctl00_ContentPlaceHolder1_hidUser");
			    var hidUser=document.getElementById("<%= hidUser.ClientID%>");
			    hidUser.value="aaa";
			    imgState.style.visibility="visible";
			    if(flag=="yes")
			    {
			        imgState.src="../../Images/Icon/cmdDelete.gif";
			        imgState.alt="Tên này đã tồn tại";
			        hidUser.value="0";
			    }
			    else
			    {
			        imgState.src="../../Images/Icon/check.gif";
			        imgState.alt="Bạn được sử dụng tên này";
			    }
			}	
        }
    }
    
/*=================Email================*/
    function fnHideImgEmail()
    {
        var imgStateEmail=document.getElementById("imgStateEmail");
        imgStateEmail.style.visibility="hidden"; 
    }
    function fnCheckEmail(sValue)
    {      
         if(sValue.trim()=="")
        {   
            var hidEmail=document.getElementById("<%= hidEmail.ClientID%>");
            hidEmail.value="aaa";
            return;
        }
        
        var UserID="0";
        if('<%=Request.QueryString["UserID"] %>'!="" && '<%= Request.QueryString["UserID"]%>'!=null)
            UserID='<%=Request.QueryString["UserID"] %>';
        Manager_User_AddCustomer.AjaxCheckEmail(sValue,UserID,CallBackEmail);  

     
    }
    function CallBackEmail(res)
    {
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgStateEmail=document.getElementById("imgStateEmail");

			    var hidEmail=document.getElementById("<%= hidEmail.ClientID%>");
			    hidEmail.value="aaa"; //Tranh su kien dang su ly
		
			    if(flag=="yes")
			    {   imgStateEmail.style.visibility="visible";
			        imgStateEmail.src="../../Images/Icon/cmdDelete.gif";
			        imgStateEmail.alt="Email này đã tồn tại";			        
			        hidEmail.value="0";
			       
			    }		
			    else
			    {
			           imgStateEmail.style.visibility="hidden";
			    }	    
			}	
        }
    }
    function IsAutoPassWord()
    {
        
        
        var chkAutoPass=document.getElementById("<%=chkAutoPass.ClientID %>");
        var  trPass1=document.getElementById("trPass1");
        var  trPass2=document.getElementById("trPass2");
        if(chkAutoPass.checked==true)
        {           
            trPass1.style.visibility="hidden";   
            trPass2.style.visibility="hidden";  
            trPass1.style.display="none";   
            trPass2.style.display="none";      
            document.getElementById("RequiredFieldValidator8").validationGroup="GrRegisterInVisible";   
            document.getElementById("<%=txtPassword.ClientID %>").value="";
        }
        else
        {
            document.getElementById("RequiredFieldValidator8").validationGroup="GrRegister";
            trPass1.style.visibility="visible";   
            trPass2.style.visibility="visible"; 
            trPass1.style.display="block";   
            trPass2.style.display="block";   
        }
    }
    
        </script>

    </form>
</body>
</html>
